<template>
  <div class="perList">

    <!-- 面包屑导航开始 -->
    <el-breadcrumb separator="/" class="crumbs mt-15">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>角色</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 面包屑导航结束 -->
    <el-table :data="tableData" border style="width: 100%" class="mt-15">
      <el-table-column type="index" width="50">
      </el-table-column>
      <el-table-column prop="authName" label="权限名称" width="420">
      </el-table-column>
      <el-table-column prop="path" label="路径" width="420">
      </el-table-column>
      <el-table-column label="层级" width="420">
        <template slot-scope="scope">
          <el-tag v-if='scope.row.level==="0"'>{{scope.row.level|leavFilter}}</el-tag>
          <el-tag type="success" v-else-if='scope.row.level==="1"'>{{scope.row.level|leavFilter}}</el-tag>
          <el-tag type="danger" v-else>{{scope.row.level|leavFilter}}</el-tag>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { rightsData } from '@/api'
export default {
  filters: {
    leavFilter (level) {
      if (level === '0') {
        return '一级'
      } else if (level === '1') {
        return '二级'
      } else {
        return '三级'
      }
    }
  },
  data () {
    return {
      tableData: []
    }
  },
  created () {
    this.initTable()
  },
  methods: {
    initTable () {
      rightsData().then(res => {
        console.log(res)
        this.tableData = res.data
      })
    }
  }
}
</script>
<style lang="scss" scoped>
 .crumbs {
      padding: 15px;
    }
</style>
